﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Logica;
using System.Collections.Specialized;

public partial class Metodo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        String nombre_metodo = Request.QueryString["nombre"];
        if (!String.IsNullOrEmpty(nombre_metodo))
        {
            Ejecutar ej = new Ejecutar();
            ltl.Text = ej.obtenerDefinicionMetodo(nombre_metodo);
        }
        else
        {
            int iCantParametros = HttpContext.Current.Items.Count;
            
            String entradaSOAP = "<llamada funcion=\""+HttpContext.Current.Request["nombre"]+"\" clase=\""+HttpContext.Current.Request["clase"]+"\" tam=\""+HttpContext.Current.Request["tam"]+"\">";
            for (int i = 0; i < iCantParametros; i++)
            {
                entradaSOAP += "<param valor=\"" + HttpContext.Current.Request["param"+i] + "\"/>";
            }
            entradaSOAP += "</llamada>";

            entradaSOAP = HttpUtility.HtmlEncode(entradaSOAP);
            try
            {
                string url = HttpContext.Current.Request.Url.AbsoluteUri;
                url = url.Substring(0, url.LastIndexOf("/")) + "/Respuesta.aspx";
                NameValueCollection data = new NameValueCollection();
                data.Add("soap", entradaSOAP);
                HttpHelper.RedirectAndPOST(this.Page, url, data);
            }
            catch (Exception ee)
            {
            }
        }
    }
}